<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<h3>关于null, undefined和NaN等</h3>
		<ul>
			<li><button onclick="funcTest1()">运行例子</button></li>
		</ul>
		<script>
			function funcTest1(){
				document.write("null = " + null);
				var notdefined;
				document.write("<br/>");
				document.write("notdefined = " + notdefined);				// 可以运行，虽然notdefined未定义，但进行了声明
				document.write("<br/>");
				//document.write("dotdeclared = " + notdeclared);			// 运行错误，变量notdeclared未声明
				
				document.write("typeof new Number(10) = " + typeof(new Number(10)));
				document.write("<br/>");
				document.write("typeof null = " + typeof null);
				document.write("<br/>");
				document.write("null == undefined : " + (null == undefined));
				document.write("<br/>");
				document.write("null === undefined : " + (null === undefined));
				document.write("<br/>");
				document.write("NaN == NaN : " + (NaN == NaN));				// NaN与任何值都不等，包括与自己比较
				document.write("<br/>");
				document.write("typeof notdefined= " + typeof notdefined);	
				document.write("<br/>");
				document.write("typeof notdeclared= " + typeof notdeclared);	// 未声明的变量仅能被typeof所使用
				
				document.write("<br/>");
				document.write("<br/>");
				document.write("Number(\"\")=" + Number(""));
				document.write("<br/>");
				document.write("Number(null)=" + Number(null));
				document.write("<br/>");
				document.write("Number(undefined)=" + Number(notdefined));
				document.write("<br/>");
				document.write("String(null)=" + String(null));
				document.write("<br/>");
				document.write("String(undefined)=" + String(notdefined));
				document.write("<br/>");
				document.write("!(\"\") = " + !(""));
				document.write("<br/>");
				document.write("!(null) = " + !(null));
				document.write("<br/>");
				document.write("!(undefined) = " + !(notdefined));
				document.write("<br/>");
				document.write("!(NaN) = " + !(NaN));
				
				document.write("<br/>");
				document.write("\"23\" > 3 :", "23" > 3);			// 字符串被转换成数值
			}
		</script>
	
		<h3>关于语句的跳转</h3>
		<ul>
			<li><button onclick="funcTest2()">运行例子</button></li>
		</ul>
		<script>
			function funcTest2(){
				// break/continue可以跳出指定Label的循环
				var num = 0;
				outmost:
				for(var i=0;i<10;i++){
					for(var j=0;j<10;j++){
						if(i == 5 && j == 5){
							break outmost;
						}
						num++;
					}
				}
				console.log(num);
			}
		</script>
		
		<h3>关于switch的比较</h3>
		<ul>
			<li><button onclick="funcTest3()">运行例子</button></li>
		</ul>
		<script>
			function funcTest3(){
				// switch语句在进行比较时采用的是===
				var choice = "1";
				switch(choice){
					case 1:
						console.log("整数1命中。");
						break;
					case "1":
						console.log("字符串1命中");
						break;
				}
			}
		</script>
	</body>
</html>
